package com.liehu.business.controller;

import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局统一的异常处理方式
 */
@RestControllerAdvice
public class BaseController {

    /**
     * 全局统一的异常处理方式
     */

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e){
        return  new Result(false, StatusCode.ERROR,e.getMessage());
    }
}
